<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link rel="Bookmark" href="imgs/bai.ico"/>
    <link rel="Shortcut Icon" href="imgs/bai.ico"/>
    <title>个人物品</title>
    <style type="text/css">
        body { margin: 0; padding: 0; background: #eee; }
        #body { margin: 0; padding: 5%; max-width: 500px; height: 100vh; background: #fff; }
        #form { margin: 10px auto; padding: 5%; width: 70%; max-width: 500px; background: #fff; border: 1px solid #ccc; border-radius: 10px; box-shadow: 0 0 10px #ccc; }
        #form .group { margin: 10px 0; }
        #form input { margin-top: 10px; padding: 10px 5%; width: 90%; border: 1px solid #0088cc; border-radius: 5px; font-size: 16px; }
        #form button { padding: 10px 0; width: 48%; background: #0088CC; color: #fff; border: 0; border-radius: 5px; }
    </style>
</head>
<body>
<div id="body">
    <!--表单-->
    <div id="form">
        <div class="group">
            输入您的手机号
            <input type="text" placeholder="输入您的手机号" id="phone"/>
        </div>
        <div class="group">
            <button type="button" style="background-color: orange;" onclick="history.back();">返回</button>
            <button type="button" onclick="dologin();">确定</button>
        </div>
    </div>

    <!--信息弹窗-->
    <span id="msgPop"></span>
</div>
</body>
</html>


<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/view.js"></script>
<script type="text/javascript">
    var cw = document.documentElement.clientWidth;
    var ch = document.documentElement.clientHeight;
    var code = getParamByUrl('code');
    (function(){
    })();
    //设置手机号
    function dologin() {
        var h = '';
        if (code == undefined || code == '') {
            h = '<div style="margin-top: 50%; width: ' + cw + 'px; height: ' + ch + 'px; text-align: center; color: #888;">';
            h += '无效码...';
            h += '</div>';
            $('body').html(h);
            return
        }
        var phone = $('#phone').val();
        if (phone == '') {
            msgPop({msg: '手机号必填'});
            return
        }
        var formData = {
            phone: phone,
            code: code
        };
        $.ajax({
            type: apis.userPhone.method,
            url: apis.userPhone.url,
            data: formData,
            success: function (res) {
                console.log(res);
                if (res.code != 0) {
                    msgPop({msg: res.msg});
                    return
                }
                var userInfo = {
                    token: res.data.token,
                    uid: res.data.uid,
                    code: res.data.code,
                    phone: phone
                };
                setUserInfo({val: userInfo}); //设置本地缓存
                token = res.data.token;
//                setCookie(token, res.data.token, 360);
                //console.log(res.data.view); return
                if (res.data.view == '') {
                    window.location.href = '/h5' + routes.scence + '?code=' + code + '&token=' + token;
                } else {
                    window.location.href = '/h5' + res.data.view + '?code=' + code + '&token=' + token;
                }
            },
            error: function () {
                console.log('error');
            }
        });
    }
</script>